home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 027a / calcul8.zip / CALCDEMO.PRG < prev    next >
Text File  |  1991-10-03  |  4KB  |  104 lines

  1. TEXT
  2. *******************************************************************************
  3. *
  4. *  DEMONSTRATION DRIVER FOR:  This demo displays some of this header on
  5. *                             the screen because the save and replace
  6. *                              of the screen area really impresses the guy
  7. *                              who wrote this driver.
  8. *
  9. *  FUNCTION CALCUL8 - Pop up calculators for Clipper applications
  10. *                       CALC_B () has tape/no tape option
  11. *                        CALC_N () has no tape
  12. *                       CALC_T () has a tape
  13. *
  14. *
  15. *  USE:
  16. *    result = calc_b (<expN1>, <expN2>, [<expL>], [@array1>])
  17. *    result = calc_n (<expN1>, <expN2>, [@array1>])
  18. *    result = calc_b (<expN1>, <expN2>, [@array1>])
  19. *
  20. *  RETURNS:
  21. *    accumulated result of calculations (up to 99,999,999.9999
  22. *    and down to -9,999,999.999
  23. *
  24. ENDTEXT
  25. *  FOUR PARAMETERS:
  26. *    <expN1>, <expN2> - top and left position of the
  27. *                       calculator display  - REQUIRED
  28. *    <@array1>        - Four element array of colors (e.g. W/N)
  29. *                       for calculator colors (defaults are
  30. *                       listed below in parentheses COLOR:B/W):
  31. *                       array[1] - (W+/BG:W+/n ) = Calculator body
  32. *                       array[2] - (N/BG :N/w  ) = Text color
  33. *                       array[3] - (N/W  :N/W  ) = Tape/accumulator
  34. *                       array[4] - (W+*/W:W+*/W) = Error message
  35. *    <expL>           - Indicator of whether to display
  36. *                       the calculator tape (optional).  If
  37. *                        not supplied, default is .F. (no tape).
  38. *                       Note that this parameter is passed only
  39. *                       to CALC_B().
  40. *
  41. *  COMMENTS:
  42. *    CALCUL8 saves and restores the existing color scheme and
  43. *    the screen area it uses.
  44. *
  45. *    CALCUL8 identifies all its variables as PRIVATE, so it
  46. *    should not clobber any of your application's variables.
  47. *
  48. *    CALCUL8 uses two embedded functions: rithmetik and check_tape
  49. *
  50. *  LIMITATIONS:
  51. *    The top left of CALCUL8 must be within 0,0 through 13,44
  52. *    if the tape is displayed, and within 0,0 through 14,59 if
  53. *    the tape is not displayed.
  54. *
  55. *
  56. *******************************************************************************
  57.  
  58. DECLARE calc_color[4]
  59.         calc_color[1] = 'W+/BG'
  60.         calc_color[2] = 'N/BG'
  61.         calc_color[3] = 'N/W'
  62.         calc_color[4] = 'W+*/W'
  63.  
  64. SET DECIMALS TO 4
  65.  
  66. *  This demo puts the calculator in several places on the screen
  67. *  in the default colors.  It alternates between CALC_N, CALC_T, and CALC_B.
  68. *  CALC_B alternates between using the tape and not. The result is
  69. *  displayed at the top right.
  70. *
  71. *  Use Alt-C to exit
  72.  
  73. use_tape = .T.
  74.  
  75. SETCOLOR('N/W')
  76.  
  77.  
  78. DO WHILE .T.
  79.     @ 24, 0 clear to 24,79
  80.     @ 24,28 say "The 'no tape' version"
  81.     top = 10
  82.     left = 44
  83.     calc_result= calc_n(top,left)        && Calculator wo/tape
  84.     @ 0,65 SAY calc_result PICTURE '99,999,999.9999'
  85.  
  86.     @ 24,27  say "The 'with tape' version"
  87.     top = 2
  88.     left = 2
  89.     calc_result= calc_t(top,left,@calc_color)     && calculator w/tape
  90.     @ 0,65 SAY calc_result PICTURE '99,999,999.9999'
  91.  
  92.     IF use_tape
  93.          @ 24,22 SAY "The switchable version with tape ON"
  94.      ELSE
  95.          @ 24,22 SAY "The switchable version with tape OFF"
  96.      ENDIF
  97.      top = 10
  98.      left = 22
  99.      calc_result= calc_b(top,left,use_tape,@calc_color) && calculator w/select
  100.      @ 0,65 SAY calc_result PICTURE '99,999,999.9999'
  101.  
  102.      use_tape = .NOT. use_tape         && Toggle for CALC_B
  103. ENDDO
  104.